package com.wmq.mocktio;

import javax.servlet.http.HttpServletRequest;

/**
 * @authoer:WangMengqiang
 * @createDate:2023/2/8
 * @description:
 */
public class AccountLoginController {

    private final AccountDao accountDao;

    public AccountLoginController(AccountDao accountDao) {
        this.accountDao = accountDao;
    }


    public String login(HttpServletRequest request){
        final String username = request.getParameter("username");
        final String password = request.getParameter("password");
        try{
            Account account = accountDao.findAccount(username, password);
            if (account == null){
                return "/login";
            }else {
                return "/index";
            }
        }catch (Exception e){
            return "/505";
        }

    }
}
